home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 61 / Quick PC 61.iso / I386 / SASETUP.MSI / F77564_sh_task.asp < prev    next >
Encoding:
Text File  |  2003-02-21  |  23.0 KB  |  737 lines

  1. <%    '==================================================
  2.     ' Microsoft Server Appliance
  3.     '
  4.     ' Serves task wizard/propsheet
  5.     '
  6.     ' Copyright (c) Microsoft Corporation.  All rights reserved.
  7.     '================================================== %>
  8.  
  9. <!-- #include file="sh_page.asp" -->
  10. <!-- #include file="tabs.asp" -->
  11. <!-- #include file="sh_statusbar.asp" -->
  12.  
  13. <%    ' Copyright (c) Microsoft Corporation.  All rights reserved.
  14.  
  15.     'Task module-level variables
  16.     Dim mstrPageName    '    used as page identifier, e.g., "Intro"
  17.     Dim mstrTaskTitle    '    e.g., "Add User"
  18.     Dim mstrWizPageTitle    '    e.g., "Add User"
  19.     Dim mstrPageTitle    '    e.g., "Username and Password"
  20.     Dim mstrTaskType    '    "wizard", "prop"
  21.     Dim mstrWizardPageType    '    "intro", "standard", "finish"
  22.     Dim mstrMethod        '    "BACK", "NEXT", "FINISH", etc
  23.     Dim mstrReturnURL    '    URL to return to after ending task
  24.     Dim mstrFrmwrkFormStrings    ' framework form values, list of strings to exclude
  25.     Dim mstrIconPath    '    image for upper right header
  26.     Dim mstrPanelPath    '    image for left panel of intro and finish pg
  27. '    Dim mintElementIndex '    index of embedded wizard page (0 - n, -1 = no extensions)
  28. '    Dim mintElementCount '    number of embedded pages in wizard
  29.     Dim mstrErrMsg        '    used by SetErrMsg and GetErrMsg
  30.     Dim mstrAsyncTaskName    ' Task EXE name - empty if task is synchronous
  31.     Dim mstrTabPropSheetTabs()
  32.     Dim mintTabSelected
  33.     Dim intCaptionIDTask
  34.  
  35.     Dim gm_sPageTitle    ' SAK 2.0 Page Title variable
  36.     Dim gm_sBannerText ' SAK 2.0 Banner Text
  37.  
  38.  
  39.     mintTabSelected = CInt(Request.Form("TabSelected"))
  40.     Set objLocMgr = Server.CreateObject("ServerAppliance.LocalizationManager")
  41.     strSourceName = "sakitmsg.dll"
  42.     
  43.     If Err.number <> 0 Then
  44.         If ( Err.number = &H800401F3 ) Then
  45.             Response.Write("<H1>Problem:<H1>") 
  46.             Response.Write("Unable to locate a software component on the Server Appliance.<BR>")
  47.             Response.Write("The Server Appliance core software components do not appear to be installed correctly.")
  48.             
  49.         Else
  50.             Response.Write("<H1>Problem:<H1>") 
  51.             Response.Write("Server.CreateObject(ServerAppliance.LocalizationManager) failed with error code: " + CStr(Hex(Err.Number)) + " " + Err.Description)
  52.         End If
  53.         Call SA_TraceOut("SH_TASK", "Server.CreateObject(ServerAppliance.LocalizationManager) failed with error code: " + CStr(Hex(Err.Number)) )
  54.         Response.End
  55.      End If
  56.  
  57.     '-----------------------------------------------------
  58.     'START of localization content
  59.  
  60.     Dim L_BACK_BUTTON
  61.     Dim L_BACKIE_BUTTON
  62.     Dim L_NEXT_BUTTON
  63.     Dim L_NEXTIE_BUTTON
  64.     Dim L_FINISH_BUTTON
  65.     Dim L_OK_BUTTON
  66.     Dim L_CANCEL_BUTTON
  67.     Dim L_BACK_ACCESSKEY
  68.     Dim L_NEXT_ACCESSKEY
  69.     Dim L_FINISH_ACCESSKEY
  70.  
  71.     L_BACK_BUTTON  = objLocMgr.GetString(strSourceName, "&H4001001C",varReplacementStrings)
  72.     L_BACKIE_BUTTON  = objLocMgr.GetString(strSourceName, "&H4001001D",varReplacementStrings)
  73.     L_NEXT_BUTTON  = objLocMgr.GetString(strSourceName, "&H4001001E",varReplacementStrings)
  74.     L_NEXTIE_BUTTON  = objLocMgr.GetString(strSourceName, "&H4001001F",varReplacementStrings)
  75.     L_FINISH_BUTTON  = objLocMgr.GetString(strSourceName, "&H40010020",varReplacementStrings)
  76.     L_OK_BUTTON = objLocMgr.GetString(strSourceName, "&H40010021",varReplacementStrings)
  77.     L_CANCEL_BUTTON = objLocMgr.GetString(strSourceName, "&H40010022",varReplacementStrings)
  78.     L_BACK_ACCESSKEY = objLocMgr.GetString(strSourceName, "&H40010039",varReplacementStrings)
  79.     L_NEXT_ACCESSKEY = objLocMgr.GetString(strSourceName, "&H4001003A",varReplacementStrings)
  80.     L_FINISH_ACCESSKEY = objLocMgr.GetString(strSourceName, "&H4001003B",varReplacementStrings)
  81.  
  82.     'End  of localization content
  83.     '-----------------------------------------------------
  84.  
  85.  
  86.  
  87.     'Task Constants
  88.     Const PROPERTY_TASK_NICE_NAME = "TaskNiceName"
  89.     Const PROPERTY_TASK_URL = "TaskURL"
  90.     Const WBEM_E_PROVIDER_NOT_CAPABLE = "&H80041024"
  91.     Const WIZARD_TASK = "wizard"
  92.     Const PROPSHEET_TASK = "prop"
  93.     Const TAB_PROPSHEET  = "TabPropSheet"
  94.     Const BODY_PAGE = "standard"
  95.     Const INTRO_PAGE = "intro"
  96.     Const FINISH_PAGE = "finish"
  97.     Const BACK_METHOD = "BACK"
  98.     Const NEXT_METHOD = "NEXT"
  99.     Const FINISH_METHOD = "FINISH"
  100.     Const CANCEL_METHOD = "CANCEL"
  101.  
  102.  
  103.     'Get standard task values and initialize
  104.     mstrMethod = Request.Form("Method")
  105.     mstrPageName = Request("PageName")
  106.     mstrReturnURL = Request("ReturnURL")
  107.     
  108.     If mstrReturnURL = "" Then
  109.         mstrReturnURL = GetCurrentPrimaryTabURL()
  110.     End If
  111.  
  112. '    mintElementIndex = -1                                ' set later in ServeWizardEmbeds()
  113. '    mintElementCount = Request.Form("EmbedPageCount")    ' get previous value, if any
  114. '    If mintElementCount="" Then
  115. '        mintElementCount=0
  116. '    End If
  117.     mstrFrmwrkFormStrings = "!method!pagename!pagetype!tasktype!returnurl!embedpageindex!embedpagecount!commonvalues!embedvalues0!embedvalues1!embedvalues2!embedvalues3!embedvalues4!"
  118.  
  119.     Set objLocMgr = Server.CreateObject("ServerAppliance.LocalizationManager")
  120.  
  121.  
  122.     '----------------------------------------------------------------------------
  123.     '
  124.     ' Function : SA_IsAsyncTaskBusy
  125.     '
  126.     ' Synopsis : Determine if the async task is currently being executed
  127.     '
  128.     ' Arguments: TaskName(IN) - async task name
  129.     '
  130.     ' Returns  : true/false
  131.     '
  132.     '----------------------------------------------------------------------------
  133.     Public Function SA_IsAsyncTaskBusy(ByVal TaskName)
  134.         SA_IsAsyncTaskBusy = AsyncTaskBusy(TaskName)
  135.     End Function
  136.  
  137.     Private Function AsyncTaskBusy(ByVal TaskName)
  138.  
  139.         Dim objTask
  140.  
  141.  
  142.         Set objTask = GetObject("WINMGMTS:" & SA_GetWMIConnectionAttributes() &"!\\" & GetServerName & "\root\cimv2:Microsoft_SA_Task.TaskName=" & Chr(34) & TaskName & Chr(34) )
  143.         If ( Err.Number <> 0 ) Then
  144.             Call SA_TraceOut(SA_GetScriptFileName(), "Get Microsoft_SA_Task failed: " + CStr(Hex(Err.Number)) + " " + Err.Description)
  145.             Exit Function
  146.         End If
  147.         
  148.         If Not objTask.IsAvailable Then
  149.             AsyncTaskBusy = True
  150.         Else
  151.             AsyncTaskBusy = False
  152.         End If
  153.         Set objTask = Nothing
  154.  
  155.     End Function
  156.  
  157.  
  158.     Public Function SAI_GetBannerText()
  159.         If ( SA_GetVersion() < gc_V2 ) Then
  160.             SAI_GetBannerText = mstrTaskTitle
  161.         Else
  162.             SAI_GetBannerText = gm_sBannerText
  163.         End If
  164.     End Function
  165.     
  166.     Public Function SAI_GetPageTitle()
  167.         If ( SA_GetVersion() < gc_V2 ) Then
  168.             SAI_GetPageTitle = mstrTaskTitle
  169.         Else
  170.             SAI_GetPageTitle = gm_sPageTitle
  171.         End If
  172.     End Function
  173.  
  174.     '----------------------------------------------------------------------------
  175.     '
  176.     ' Function : SA_SetErrMsg
  177.     '
  178.     ' Synopsis : Sets framework error message string
  179.     '
  180.     ' Arguments: Message(IN) - error message text
  181.     '
  182.     ' Returns  : Nothing
  183.     '
  184.     '----------------------------------------------------------------------------
  185.     Public Function SA_SetErrMsg(ByVal Message)
  186.         mstrErrMsg = Message
  187.     End Function
  188.     
  189.     Private Function SetErrMsg(ByVal Message)
  190.         mstrErrMsg = Message
  191.     End Function
  192.     '----------------------------------------------------------------------------
  193.     '
  194.     ' Function : GetErrMsg
  195.     '
  196.     ' Synopsis : Gets the current framework error message string
  197.     '
  198.     ' Arguments: None
  199.     '
  200.     ' Returns  : None
  201.     '
  202.     '----------------------------------------------------------------------------
  203.     Private Function GetErrMsg()
  204.         GetErrMsg = mstrErrMsg
  205.     End Function
  206.  
  207.  
  208.     '----------------------------------------------------------------------------
  209.     '
  210.     ' Function : ServeTaskHeader
  211.     '
  212.     ' Synopsis : Serve the task header based on page type
  213.     '
  214.     ' Arguments: None
  215.     '
  216.     ' Returns  : None
  217.     '
  218.     '----------------------------------------------------------------------------
  219.  
  220.     Function ServeTaskHeader()
  221.         Dim objItem
  222.         Dim i
  223.         Dim intSlack
  224.  
  225.         Response.Buffer = True
  226. %>
  227. <html>
  228. <!-- Microsoft(R) Server Appliance Platform
  229.      Copyright (c) Microsoft Corporation.  All rights reserved.
  230.      -------------------------------------------------
  231.      Web Framework <%=SA_TaskToPageType()%>
  232.      -------------------------------------------------
  233. -->
  234. <meta http-equiv="Content-Type" content="text/html; charset=<%=GetCharSet()%>">
  235. <head>
  236. <title><%=Server.HTMLEncode(SAI_GetPageTitle())%></title>
  237. <script language=JavaScript src="<%=m_VirtualRoot%>sh_page.js"></script>
  238. <script language=JavaScript>
  239.     var VirtualRoot = '<%=m_VirtualRoot%>';
  240.     
  241.     function HandleClickEvent()
  242.         {
  243.         if ( IsIE() )
  244.             {
  245.             if (window.event.srcElement.tagName == "INPUT")
  246.                 return true;
  247.             else
  248.                 return false;
  249.             }
  250.         else return true;
  251.         }
  252. </script>
  253. <script language=JavaScript src="<%=m_VirtualRoot%>sh_task.js"></script>
  254. <%            
  255.     If (mstrTaskType = PROPSHEET_TASK) then
  256.            If ( SA_GetVersion() < gc_V2 ) Then
  257.             Call SA_EmitAdditionalStyleSheetReferences("")
  258.         End If
  259.     End If
  260. %>        
  261. </head>
  262. <BODY onload="PageInit();" onDragDrop="return false;" xoncontextmenu="return false;">
  263. <%
  264. If (mstrTaskType= TAB_PROPSHEET) then
  265.        If ( SA_GetVersion() < gc_V2 ) Then
  266.            Call ServeTabBar()
  267.     End If
  268. End If
  269. If( (mstrTaskType="wizard") AND (mstrWizardPageType="intro" OR mstrWizardPageType="finish")) Then 
  270.  
  271. %>
  272. <div class='PageBodyIndent'>
  273. <% 
  274.     Call ServeStandardHeaderBar(SAI_GetBannerText(), mstrIconPath)
  275. %>
  276. <br>
  277. <TABLE width=87% height=65% border=0 cellspacing=0 cellpadding=0 ID=TASKTABLE>
  278. <TR valign=TOP style="background-color:#FFFFFF">
  279.     <TD height=100% xwidth="10%" align="right" valign=TOP class=PageHeaderBar style="width:130px; xbackground-color: #313163" rowspan="2">
  280. <%
  281.     If ( Len(Trim(mstrPanelPath)) > 0 ) Then 
  282. %>
  283.         <IMG width=130 border=0 src='<% =m_VirtualRoot + mstrPanelPath %>' >
  284. <%
  285.     End If
  286. %>
  287.     </td>
  288.     <td width=10> </td>
  289.     <TD valign=TOP class="TasksBody">
  290.                 <div class="PageTitleText"><%=Server.HTMLEncode(mstrWizPageTitle)%></div>
  291.  
  292.     <br>
  293. <% 
  294. Else
  295.     If (mstrTaskType= TAB_PROPSHEET) Then
  296. %>
  297.         <div class='PageBodyIndent'>
  298. <% 
  299.         Call ServeStandardHeaderBar(SAI_GetBannerText(), mstrIconPath) 
  300. %>
  301.  
  302.         <br>
  303.         <div class='PageBodyInnerIndent'>
  304.         <TABLE width=87%  border=0 height="65%" cellspacing=0 cellpadding=0 ID=TASKTABLE >
  305.            <TR height="100%" width="100%" valign=TOP>
  306.             <TD>
  307. <% 
  308.             If IsIE() Then 
  309. %>
  310.                 <TABLE class="TabPropTabTable" height="100%" width="100%" border=0 cellspacing=0 cellpadding=0>
  311. <% 
  312.             Else 
  313. %>
  314.                 <TABLE class="TabPropTabTable" height="500px" width="100%" border=0 cellspacing=0 cellpadding=0>
  315. <% 
  316.             End If
  317. %>
  318.                 <TR valign=TOP>
  319.                     <TD width="20%" height=100%>
  320.                         <TABLE xheight="100%" width="100%" border=0 cellspacing=0 cellpadding=0>
  321. <%
  322.                     intSlack = UBound(mstrTabPropSheetTabs) - LBound(mstrTabPropSheetTabs)
  323.                     intSlack = 100 - (2 * intSlack)
  324.                     If intSlack <= 0 Then
  325.                         intSlack = 5
  326.                     End If
  327.  
  328.                     
  329.                     For i = LBound(mstrTabPRopSheetTabs) to UBound(mstrTabPropSheetTabs)-1 
  330.                     Response.Write("<TR align=left height=20>"+vbCrLf)
  331.                     If mintTabSelected=i Then
  332.                         Response.Write("<TD nowrap class=TabPropTabSelected>"+vbCrLf)
  333.                     Else
  334.                         Response.Write("<TD nowrap class=TabPropTab>"+vbCrLf)
  335.                     End If
  336.                             'Response.Write("<a href=""javascript:if (ValidatePage()) {SetData(); top.main.document.forms['frmTask'].TabSelected.value="+ CStr(i) +"; top.main.document.forms['frmTask'].submit();}"">"+vbCrLf)
  337.                             Response.Write("<a onmouseover=""window.status=''; return true;""  href=""javascript:SA_OnClickTab("+ CStr(i) +");"">")
  338.                             If mintTabSelected=i Then
  339.                                 Response.Write("<span id='PropTab_"+CStr(i)+"' style=""overflow:visible;"" class=TabPropTabSelectedNoBorder>")
  340.                             Else
  341.                                 Response.Write("<span id='PropTab_"+CStr(i)+"' style=""overflow:visible;"" class=TabPropTabNoBorder>")
  342.                             End If
  343.                             Response.Write(Server.HTMLEncode(mstrTabPropSheetTabs(i)))
  344.                             Response.Write("</span>")
  345.                             Response.Write("</a>"+vbCrLf)
  346.                             Response.Write("</TD>"+vbCrLf)
  347.                             Response.Write("</TR>"+vbCrLf)
  348.                     Next
  349. %>                    
  350.                         </TABLE>
  351.                         <TABLE height="<%=intSlack%>%" width="100%" border=0 cellspacing=0 cellpadding=0>
  352.                         <TR xheight="<%=intSlack%>%">
  353.                             <TD class="TabPropTab"> </TD>
  354.                         </TR>
  355.                         </TABLE>
  356.                     </TD>
  357.                     <TD height="100%">
  358.                     <div>
  359. <% 
  360.                     If IsIE() Then 
  361. %>
  362.                         <TABLE onClick='return HandleClickEvent();' height="100%" width="100%" border=0 cellspacing=0>
  363. <% 
  364.                     Else 
  365. %>
  366.                         <TABLE onClick='return HandleClickEvent();' height="500px" width="100%" border=0 cellspacing=0>
  367. <% 
  368.                     End If 
  369. %>
  370.                         <TR height="100%" width="100%"><TD class=TabPropTabTaskCell valign=top>
  371.                         
  372. <% 
  373.     '
  374.     ' Wizard Page Type
  375.     '
  376.     ElseIf (mstrTaskType="wizard") Then
  377. %>
  378.         <div class='PageBodyIndent'>
  379. <% 
  380.         Call ServeStandardHeaderBar(SAI_GetBannerText(), mstrIconPath) 
  381. %>
  382.         <div class='PageBodyInnerIndent'>
  383.         <TABLE width=100%  border=0 height="58%" cellspacing=0 cellpadding=0 ID=TASKTABLE >
  384.         <TR valign=TOP height="10%" style="xbackground-color:#FFFFFF">
  385.             <TD valign=TOP>
  386.                 <div class="PageTitleText"><%=Server.HTMLEncode(mstrWizPageTitle)%></div>
  387.             </TD>
  388.         </TR>
  389.     
  390.         <TR height="80%" valign=TOP>
  391.             <TD valign="top" height="70%">
  392.                 <table onClick='return HandleClickEvent();' width=90% class="TasksBody"><tr><td class="TasksBody" width=100% height=100%>
  393. <% 
  394.     '
  395.     ' Property page
  396.     '
  397.     Else
  398.            If ( SA_GetVersion() < gc_V2 ) Then
  399.             Call SA_ServeStatusBar()
  400.             Call ServeTabBar()
  401.         End If
  402. %>
  403.  
  404.         <TABLE width=100%  border=0 height="58%" cellspacing=0 cellpadding=0 ID=TASKTABLE >
  405.         <TR valign=TOP height="10%" >
  406.             <TD valign=TOP>
  407.                 <div class='PageBodyIndent'>
  408. <% 
  409.             Call ServeStandardHeaderBar(SAI_GetBannerText(), mstrIconPath) 
  410. %>
  411.                 <div class="PageTitleText"><% =mstrPageTitle %></div>
  412.                 </div>
  413.             </TD>
  414.         </TR>
  415.     
  416.         <TR height="80%" valign=TOP>
  417.             <TD valign="top" height="70%">
  418.                 <div class='PageBodyIndent'>
  419.                 <table onClick='return HandleClickEvent();' width=90% class="TasksBody"><tr><td class="TasksBody" width=100% height=100%>
  420.                 <div class='PageBodyInnerIndent'>
  421. <%
  422.     End If
  423. End If
  424. %>
  425. <FORM name="frmTask" onSubmit="return Next();" action="<% =GetScriptFileName %>" method="POST">
  426. <INPUT name="<%=SAI_FLD_PAGEKEY%>" type="hidden" value="<%=SAI_GetPageKey()%>">
  427. <INPUT name="PageName" type="hidden" value="<% =mstrPageName %>">
  428. <INPUT name="Method" type="hidden" value="<% =mstrMethod %>">
  429. <INPUT name="ReturnURL" type="hidden" value="<% =mstrReturnURL %>">
  430. <INPUT name="TaskType" type="hidden" value="<% =mstrTaskType %>">
  431. <INPUT name="PageType" type="hidden" value="<% =mstrWizardPageType %>">
  432. <INPUT name="TabSelected" type="hidden" value="<% =mintTabSelected%>">
  433. <INPUT name="Tab1" type="hidden" value="<% =GetTab1() %>">
  434. <INPUT name="Tab2" type="hidden" value="<% =GetTab2() %>">
  435. <%        
  436.  
  437. ServeTaskHeader = True
  438.  
  439. End Function
  440.  
  441.  
  442.     '----------------------------------------------------------------------------
  443.     '
  444.     ' Function : ServeTaskFooter
  445.     '
  446.     ' Synopsis : Serve the task footer (navigation buttons & error div)
  447.     '            Note: The function relies on the following module-level variables:
  448.     '                   mstrTaskType - prop wizard
  449.     '                   mstrWizardPageType - standard intro finish failure
  450.     '
  451.     ' Arguments: None
  452.     '
  453.     ' Returns  : None
  454.     '
  455.     '----------------------------------------------------------------------------
  456.  
  457. Function ServeTaskFooter()
  458.  
  459.     dim ErrMessage
  460.  
  461.     Response.write("</td></tr>")
  462.  
  463.  
  464.     If GetErrMsg <> "" Then
  465.         ErrMessage = "<table class='ErrMsg'><tr><td><img src='" & m_VirtualRoot & "images/critical_error.gif' border=0></td><td>" & GetErrMsg & "</td></tr></table>"
  466.         SetErrMsg ""
  467.     else
  468.         ErrMessage =""
  469.     End If
  470.     
  471.     If( (mstrWizardPageType<>"intro_xxx") AND (mstrWizardPageType<>"finish_zzzz") ) Then 
  472.        If (IsIE()) Then %>
  473.        <tr><td colspan=2>
  474.         <DIV name="divErrMsg" ID="divErrMsg" class="ErrMsg"><%=ErrMessage%></DIV>
  475.        </td></tr>
  476.        <% End If %>
  477.  
  478.        <% If (mstrTaskType= TAB_PROPSHEET) then %>
  479.         </table>
  480.          </div>
  481.         </td></tr></table>
  482.         </td></tr></table>
  483.          </div>
  484.          </div>
  485.          
  486.        <% Else %>
  487.         </table>
  488.         </td></tr></table>
  489.          </div>
  490.          </div>
  491.        <% End If %>
  492.     <% End If %>
  493.  
  494.  
  495.         <% If Not IsIE() Then %>
  496.             <layer name="layErrMsg"  class="ErrMsg"><%=ErrMessage%></layer>
  497.         <% End If %>
  498.  
  499. <%
  500.     Response.Write "</form></BODY></HTML>"
  501.  
  502.     End Function
  503.  
  504.  
  505.  
  506.     '----------------------------------------------------------------------------
  507.     '
  508.     ' Function : ServeFailurePage
  509.     '
  510.     ' Synopsis : Serve the page which redirects the browser to the err_view.asp
  511.     '            failure page
  512.     '
  513.     ' Arguments: Message(IN) - message to be displayed by err_view.asp
  514.     '            intTab(IN)  - Tab to be highlighted by err_view.asp
  515.     '
  516.     ' Returns  : None
  517.     '
  518.     '----------------------------------------------------------------------------
  519.  
  520.     Function ServeFailurePage(Message, intTab)
  521.         Call SA_ServeFailurePage(Message)
  522.         Exit Function
  523.     End Function
  524.  
  525.  
  526.     '----------------------------------------------------------------------------
  527.     '
  528.     ' Function : ServeClose
  529.     '
  530.     ' Synopsis : Redirect user to the page from which the wizard was launched
  531.     '
  532.     ' Arguments: None
  533.     '
  534.     ' Returns  : None
  535.     '
  536.     '----------------------------------------------------------------------------
  537.  
  538.             
  539.     Sub ServeClose
  540. %>
  541.         <html>
  542.         <!-- Copyright (c) Microsoft Corporation.  All rights reserved.-->
  543.         <head>
  544.         <SCRIPT language=JavaScript>
  545.         function Redirect()
  546.         {
  547.             top.location='<%=EscapeQuotes(mstrReturnURL)%>';
  548.         }
  549.         </SCRIPT>
  550.         </head>
  551.         <BODY onLoad="Redirect();">
  552.          
  553.         </BODY>
  554.         </html>
  555. <%        
  556.     End Sub
  557.  
  558.  
  559.  
  560.  
  561.     '----------------------------------------------------------------------------
  562.     '
  563.     ' Function    SA_ExecuteTask
  564.     '
  565.     ' Synopsis    Executes an Appliance Task backend object. Normally, backend Tasks
  566.     '            are executed synchronously. The bExecuteAsync parameter allows overriding
  567.     '            the default behavior. 
  568.     '
  569.     '            If the oTaskContext object has not been created and initialized, this function
  570.     '            will create a default oTaskContext and will initialize it by creating task 
  571.     '            parameters using all input form fields from the current Request object. This
  572.     '            makes it easy to pass an HTML form to the appliance task.
  573.     '
  574.     '            If an error is encountered the really is no reasonable recovery that a 
  575.     '            scripting client can make. 
  576.     '
  577.     ' Arguments    [in] TaskName        Name of task to execute
  578.     '
  579.     '            [in] bExecuteAsync    Flag indicating if Task should be executed
  580.     '                                synchronisly (default, FALSE) or async (TRUE).
  581.     '
  582.     '            [in/out] oTaskContext TaskContext object for the appliance task. The TaskContext
  583.     '                                object can be used to pass input arguments to the Task.
  584.     '
  585.     ' Returns:
  586.     ' SA_NO_ERROR 
  587.     '        The call succeeded, no errors occured
  588.     '
  589.     ' SA_ERROR_CREATE_OBJECT_FAILED     
  590.     '        Unable to create one of the required backend objects, this indicates that either the 
  591.     '        components were not installed correctly or that the Appliance Manager service
  592.     '        is not running.
  593.     '
  594.     ' SA_ERROR_INITIALIZE_OBJECT_FAILED    
  595.     '        The Task object encountered an unrecoverable error during it's internal initialization.
  596.     '        This is probably not recoverable and likely indicates a problem with either the expected
  597.     '        inputs or the current state of the Appliance task. 
  598.     '
  599.     ' All other cases
  600.     '        The HRESULT return value recieved from the Task
  601.     '
  602.     '
  603.     ' Example 1 - Create TaskContext and set input parameters:
  604.     '        Dim oTaskContext
  605.     '        Dim rc
  606.     '
  607.     '        Set oTaskContext = CreateObject("Taskctx.TaskContext")
  608.     '        If Err.Number <> 0 Then
  609.     '            ' Handle the error
  610.     '            Exit Function
  611.     '        End If
  612.     '
  613.     '        Call oTaskContext.SetParameter("Method Name", strMethodName)
  614.     '        Call oTaskContext.SetParameter("LanguageID", strLANGID)
  615.     
  616.     '        Call oTaskContext.SetParameter("AutoConfig", "y")
  617.     '
  618.     '        rc = SA_ExecuteTask("ChangeLanguage", FALSE, oTaskContext)
  619.     '        If ( rc <> SA_NO_ERROR ) Then
  620.     '            ' Handle the error
  621.     '        End If
  622.     '    
  623.     ' Example 2 - Use the current input form (Request object) as input to the task
  624.     '        Dim rc
  625.     '        Dim oTaskContext
  626.         
  627.     '        Set oTaskContext = nothing
  628.     '        rc = SA_ExecuteTask("MyApplianceTask", FALSE, oTaskContext)
  629.     '        If ( rc <> SA_NO_ERROR ) Then
  630.     '            ' Handle the error
  631.     '        End If
  632.     '----------------------------------------------------------------------------
  633.  
  634.     '
  635.     ' Following signature has been deprecated in SAK 2.0 - See SA_ExecuteTask
  636.     Private Function ExecuteTask(ByVal TaskName, ByRef oTaskContext)
  637.         ExecuteTask = SA_ExecuteTask(TaskName, FALSE, oTaskContext)
  638.     End Function
  639.  
  640.  
  641.     Public Function SA_ExecuteTask(ByVal TaskName, ByVal bExecuteAsync, ByRef oTaskContext)
  642.         on error resume next
  643.         Err.Clear
  644.         
  645.         Dim objAS
  646.         Dim objValue
  647.         Dim objElementCol
  648.         Dim objElement
  649.         Dim oField
  650.         Dim rc
  651.  
  652.         SA_ExecuteTask = SA_NO_ERROR
  653.  
  654.         '
  655.         ' Create default TaskContext object if necessary
  656.         '
  657.         If (NOT IsObject(oTaskContext)) Then
  658.             Call SA_TraceOut("SH_TASK", "SA_ExecuteTask - Creating default TaskContext")
  659.             Set oTaskContext = Server.CreateObject("Taskctx.TaskContext")
  660.             If (Err.Number <> 0) Then
  661.                 Call SA_TraceErrorOut(SA_GetScriptFileName(), "Server.CreateObject(Taskctx.TaskContext) failed: " + CStr(Hex(Err.Number)) + " " + Err.Description)
  662.                 SA_ExecuteTask = SA_ERROR_CREATE_OBJECT_FAILED
  663.                 Exit Function
  664.             End If
  665.             
  666.             '
  667.             ' Set default value of parameters
  668.             For Each oField in Request.Form
  669.                 oTaskContext.SetParameter oField, CStr(Request.Form(oField))
  670.             Next
  671.         End If
  672.  
  673.         
  674.         '
  675.         ' Get interface to ApplianceServices interface, the object that allows us to invoke tasks
  676.         Set objAS = Server.CreateObject("Appsrvcs.ApplianceServices")
  677.         If (Err.Number <> 0) Then
  678.             Call SA_TraceErrorOut(SA_GetScriptFileName(), "Server.CreateObject(Appsrvcs.ApplianceServices) failed: " + CStr(Hex(Err.Number)) + " " + Err.Description)
  679.             SA_ExecuteTask = SA_ERROR_CREATE_OBJECT_FAILED
  680.             Exit Function
  681.         End If
  682.  
  683.         '
  684.         ' Initialize ApplianceServices object
  685.         objAS.Initialize()
  686.         If (Err.Number <> 0) Then
  687.             Call SA_TraceErrorOut(SA_GetScriptFileName(), "objAS.Initialize() for object Appsrvcs.ApplianceServices failed: " + CStr(Hex(Err.Number)) + " " + Err.Description)
  688.             SA_ExecuteTask = SA_ERROR_INITIALIZE_OBJECT_FAILED
  689.             Exit Function
  690.         End If
  691.         
  692.         '
  693.         ' Initialize context parameters
  694.         oTaskContext.SetParameter PROPERTY_TASK_NICE_NAME, mstrTaskTitle
  695.         oTaskContext.SetParameter PROPERTY_TASK_URL, m_VirtualRoot + GetScriptPath()
  696.         
  697.         Err.Clear
  698.         
  699.         If ( TRUE = bExecuteAsync ) Then
  700.             'Call SA_TraceOut("SH_TASK", "Calling objAS.ExecuteTaskAsync("+TaskName+", oTaskContext)")
  701.             Call objAS.ExecuteTaskAsync(TaskName, oTaskContext)
  702.         Else
  703.             'Call SA_TraceOut("SH_TASK", "Calling objAS.ExecuteTask("+TaskName+", oTaskContext)")
  704.             Call objAS.ExecuteTask(TaskName, oTaskContext)
  705.         End If
  706.  
  707.         If ( Err.Number <> 0 ) Then
  708.             SA_ExecuteTask = Err.Number
  709.             Call SA_TraceErrorOut(SA_GetScriptFileName(), "Task execution returned failure code: " + CStr(Hex(Err.Number)) + " " + Err.Description)
  710.         End If
  711.  
  712.         objAS.Shutdown()
  713.         Err.Clear
  714.         
  715.         Set objAS = Nothing
  716.  
  717.     End Function
  718.  
  719.  
  720.  
  721.     Private Function SA_TaskToPageType()
  722.     
  723.         If ( mstrTaskType = "prop" ) Then
  724.             SA_TaskToPageType = "Property Page"
  725.         ElseIf ( mstrTaskType = TAB_PROPSHEET) Then
  726.             SA_TaskToPageType = "Tabbed Property Page"
  727.         ElseIf ( mstrTaskType = "wizard") Then
  728.             SA_TaskToPageType = "Wizard Page"
  729.         Else
  730.             SA_TaskToPageType = "Unknown Page Type"
  731.         End If
  732.         
  733.     End Function
  734.     
  735.     %>
  736.     
  737.